import request from "./http"

function getCourses(type, pageSize = "5", pageNum = "1") {
    const parmas = new URLSearchParams();
    parmas.append("type", type);
    parmas.append("pageNum", pageNum);
    parmas.append("pageSize", pageSize);
    const url = '/api/weChat/applet/course/list/type'
    return request.post(url, parmas)
}
function shufflingFigure(number=5){
    let url=`/api/weChat/applet/course/banner/list?number=${number}`
    return request.get(url)
}
function courseDetail(courseId){
    let url=`/api/pc/course/detail/${courseId}`
    return request.get(url)
}
//登录接口
function loginDetail(username, password, rememberMe =true) {
    const parmas = new URLSearchParams();
    parmas.append("username", username);
    parmas.append("password", password);
    parmas.append("rememberMe", rememberMe);
    const url = '/api/pcUser/login'
    return request.post(url, parmas)
}
//购物车接口
function shoppingCar(){
    let url=`/api/weChat/applet/shoppingCart/my/list`
    return request.get(url)
}
//获取专题列表
function projectList(enable) {
    const url = '/api/weChat/applet/subject/list'
    return request.post(url,{enable:enable})
}

function getfriend() {
    const url = `/api/system/dict/data/list/open?dictType=blogroll&pageNum=1&pageSize=10&orderByColumn=dictSort&isAsc=asc`;
    return request.post(url)

}

//退出登录状态
function logOutLogin(){
    let url=`/api/pcUser/logout`
    return request.get(url)
}

//路由拦截个人信息接口
function peopleMessage(){
    let url=`/api/pcUser/login-user/info`
    return request.get(url)
}
//添加购车数据
function addCart(courseId){
    let url=`/api/weChat/applet/shoppingCart/join/shoppingCart/${courseId}`
    return request.get(url)
}
//删除购物车数据
function deleteCart(shoppingCartId){
    let url=`/api/weChat/applet/shoppingCart/remove/${shoppingCartId}`
    return request.get(url)
}
export {getCourses,shufflingFigure,courseDetail,loginDetail,shoppingCar,projectList,getfriend,addCart,logOutLogin,peopleMessage,deleteCart}

